<?php
namespace System\Core\LogHandlers;

use System\Core\Log;

class SingleFileHandler extends BaseHandler {
    protected $filePath;
    
    public function __construct($filePath, $level = Log::DEBUG) {
        parent::__construct($level);
        $this->filePath = $filePath;
    }
    
    public function handle($level, $message, array $context = []) {
        if (!$this->isHandling($level)) {
            return;
        }
        
        $log = $this->formatMessage($level, $message, $context);
        file_put_contents($this->filePath, $log, FILE_APPEND);
    }
}